<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <input type="file" id="file">
    <script>
        var file = document.querySelector('#file')
        file.onchange = function(){
            var fd = new FormData()
            fd.append('attrName',this.files[0])
            var xhr = new XMLHttpRequest()
            xhr.open('post','/upload')
            xhr.send(fd)
            xhr.onload = function(){
                if(xhr.status == 200){
                    var src = JSON.parse(xhr.responseText).path
                    var img = new Image()
                    img.src = src 
                    img.onload = function(){
                        document.body.appendChild(img)
                    }
                }
            }
        }
    </script>
</body>
</html>